package com.lagou.rpc.consumer.controller;

import com.lagou.rpc.api.IUserService;
import com.lagou.rpc.consumer.proxy.RpcClientProxy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户处理类
 *
 * @Author: zhangzhiwei
 * @Date: 2022/2/5 22:55
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private RpcClientProxy rpcClientProxy;

    @GetMapping("/{id}")
    public Object getUserById(@PathVariable("id") Integer id){

        IUserService userService = (IUserService) rpcClientProxy.createProxy(IUserService.class);
        return userService.getById(id);

    }

}
